home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 19 / madtrb14.zip / SIGCHI.PAS < prev    next >
Pascal/Delphi Source File  |  1985-05-17  |  3KB  |  55 lines

  1. (*-------------------------------------------------------------------------*)
  2. (*          SigChi -- Significance of Chi-Square distribution              *)
  3. (*-------------------------------------------------------------------------*)
  4.  
  5. FUNCTION SigChi( Chisq , Df : REAL ) : REAL;
  6.  
  7. (*-------------------------------------------------------------------------*)
  8. (*                                                                         *)
  9. (*       Function:  SigChi                                                 *)
  10. (*                                                                         *)
  11. (*       Purpose:   Evaluates Chi-Square distribution probability          *)
  12. (*                                                                         *)
  13. (*       Calling Sequence:                                                 *)
  14. (*                                                                         *)
  15. (*            P     := SigChi( Chisq , Df );                               *)
  16. (*                                                                         *)
  17. (*                 Chisq  --- Chi-square value                             *)
  18. (*                 Df     --- Degrees of freedom                           *)
  19. (*                                                                         *)
  20. (*                 P      --- Resultant probability                        *)
  21. (*                                                                         *)
  22. (*       Calls:                                                            *)
  23. (*                                                                         *)
  24. (*            GammaIn                                                      *)
  25. (*                                                                         *)
  26. (*       Method:                                                           *)
  27. (*                                                                         *)
  28. (*            The input values are transformed to match the                *)
  29. (*            requirements of the Gamma distribution.  Function GammaIn    *)
  30. (*            provides the corresponding cumulative incomplete gamma       *)
  31. (*            probability.                                                 *)
  32. (*                                                                         *)
  33. (*            An error in the input arguments results in a returned        *)
  34. (*            probability of -1.                                           *)
  35. (*                                                                         *)
  36. (*-------------------------------------------------------------------------*)
  37.  
  38. CONST
  39.    MaxIter = 200;
  40.    Dprec   = 12;
  41.  
  42. VAR
  43.    Ierr:  INTEGER;
  44.    Iter:  INTEGER;
  45.    Cprec: REAL;
  46.  
  47. BEGIN (* SigChi *)
  48.  
  49.    SigChi := 1.0 - GammaIn( Chisq / 2.0, Df / 2.0, Dprec, MaxIter,
  50.                             Cprec, Iter, Ierr );
  51.  
  52.    IF ( Ierr <> 0 ) THEN SigChi := -1.0;
  53.  
  54. END   (* SigChi *);
  55.